﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Warehouse.UI.WinForm.Controls
{
    public partial class PanelSaveUndo : UserControl
    {
        //public delegate void MyEventHandler(object sender, EventArgs e);
        public event System.EventHandler btnSaveClick = null;
        public event System.EventHandler btnUndoClick = null;

        public PanelSaveUndo()
        {
            InitializeComponent();
            this.btnSave.Text = "保存(&S)";
            this.btnUndo.Text = "恢复(&U)";
        }

        public int RunState
        {
            set
            {
                if (value == 1)
                    this.Cursor = Cursors.WaitCursor;
                btnSave.Enabled = (value == 0);
                btnUndo.Enabled = (value == 0);
                if (value == 0)
                    this.Cursor = Cursors.Default;
            }
        }

        private void PanelSaveUndo_Load(object sender, EventArgs e)
        {

        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            this.RunState = 1;
            try
            {
                if (btnSaveClick != null) btnSaveClick(btnSave, e);
            }
            finally
            {
                this.RunState = 0;
            }
        }

        private void btnUndo_Click(object sender, EventArgs e)
        {
            this.RunState = 1;
            try
            {
                if (btnUndoClick != null) btnUndoClick(btnUndo, e);
            }
            finally
            {
                this.RunState = 0;
            }
        }
    }
}
